<template>
  <view>
    <view class="nav-box">
      <u-tabs :list="list1" @change="onChange" itemStyle="padding-left: 150rpx; padding-right: 150rpx;  height: 80rpx;" lineColor="#E52D21"></u-tabs>
    </view>
    <messageList v-if="navIndex==0" :announcement='announcement'></messageList>
    <taskNotification v-else-if="navIndex==1" :messagenotice="messagenotice"></taskNotification>
  </view>
</template>

<script>
export default {
  name: '',
  components: {},
  data() {
    return {
      navIndex:0,
      list1: [
        {
          name: '公告'
        },
        {
          name: '任务通知'
        }
      ],
      announcement:[],
      messagenotice:[]
    };
  },
  created() {},
  mounted() {},
  onLoad() {
    this.getList()
    this.messageNotice()
  },
  methods: {
    async getList(){
      let { data:{data} } = await uni.$http.get('/messages/page',{
        contentType:200,
        page:"1",
        pageSize:'10'
      })
      // console.log(data);
      this.announcement = data.items
    },
    onChange({index}){
     this.navIndex = index
    },
     async messageNotice(){
      let { data:{data} }= await uni.$http.get('/messages/page',{
        contentType:201,
        page:"1",
        pageSize:'10'
      })
      this.messagenotice = data.items
    }
  }
};
</script>

<style lang="scss">
page {
  background-color: #f5f5f5;
}
.nav-box {
  display: flex;
  height: 88rpx;
  align-items: center;
  background-color: #ffffff;
}

</style>
